/*
 * @Author: 小封 258234579@qq.com
 * @Date: 2022-07-06 11:00:17
 * @LastEditors: 小封 258234579@qq.com
 * @LastEditTime: 2022-07-07 09:19:52
 * @FilePath: \三花机联网\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/components/Layout.vue'

Vue.use(VueRouter)

const routes = [
  { 
    path: '/',
    component: Layout,
    children:[
      {
        path: '',
        name:'equipmentStatus',
        component: () => import('@/views/equipmentStatus.vue')
      },
      {
        path: '/equipment',
        name: 'equipment',
        component: () => import('@/views/equipment.vue')
      },
      {
        path: '/equipmentDetail',
        name:'equipmentDetail',
        component: () => import('@/views/equipmentDetail.vue')
      },
      {
        path: '/program',
        name:'program',
        component: () => import('@/views/program.vue')
      },
    ]
  },
]

// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes
})

export default router
